package com.um.jdy.app.activity.controller;


import cn.dev33.satoken.annotation.SaCheckLogin;
import com.um.jdy.app.activity.entity.dto.MyCouponsPageDTO;
import com.um.jdy.app.activity.entity.vo.CouponsUserItemVO;
import com.um.jdy.app.activity.entity.vo.MyCouponsVO;
import com.um.jdy.app.activity.manager.CouponsUserManager;
import com.um.jdy.common.activity.enums.ActivityEnum;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;


/**
 * 控制器：优惠券用户关联表
 */
@RestController
@RequestMapping("/api/v1/coupons/user")
@Api(tags = "我的充电优惠券")
@SaCheckLogin
public class CouponsUserController {

    @Autowired
    CouponsUserManager couponsUserManager;

    @ApiOperation(value = "查询我的充电优惠券分页")
    @GetMapping("charge/page")
    public Response<Page<CouponsUserItemVO>> getChargePage(@ApiParam(value = "页码") @NotNull Integer page_no,
                                                  @ApiParam(value = "数量") @NotNull Integer page_size,
                                                  @ApiParam(value = "标题") ActivityEnum.CouponsStatus status) {

        return Response.success(couponsUserManager.getChargePage(page_no, page_size, status));
    }

    @ApiOperation("分页查询我的商品优惠券")
    @GetMapping("goods/page")
    public Response<Page<MyCouponsVO>> geGoodsPage(@Valid @ModelAttribute MyCouponsPageDTO dto){
        return Response.success(couponsUserManager.geGoodsPage(dto));
    }

}
